Skip to content

feat(sample-app): admin seed runner + datasource/JWT config for e2e#24

Merged
jlc488 merged 1 commit into
mainfrom
feat/sample-app-seed-for-e2e
May 30, 2026
Merged

feat(sample-app): admin seed runner + datasource/JWT config for e2e#24
jlc488 merged 1 commit into
mainfrom
feat/sample-app-seed-for-e2e

Conversation

@jlc488

@jlc488 jlc488 commented May 30, 2026

Copy link
Copy Markdown
Contributor

Sets up the sample app so the admin UI can log in immediately. Needed for end-to-end verification of the full stack (admin-ui + devslab-kit) — previously the app booted with zero users and the UI's login screen had nothing to authenticate against.

Seed runner

SampleSeedRunner is an ApplicationRunner bean registered by SampleApplication. On first boot it provisions:

  • Tenant default
  • Role PLATFORM_ADMIN bound to that tenant
  • 16 admin.* permissions covering every admin-api endpoint:
    • admin.user.read/write, admin.role.read/write, admin.permission.read/write, admin.group.read/write, admin.menu.read/write, admin.tenant.read/write
    • admin.policy.test, admin.audit.read, admin.diagnostics.run, admin.settings.read
  • Each admin.* permission granted to PLATFORM_ADMIN
  • User admin / admin (overridable) holding PLATFORM_ADMIN

Every step is idempotent (findByCode / findByLoginId before create). Re-running on an already-seeded DB is a no-op.

SampleSeedProperties (sample.seed.*)

Property Default Override
enabled true SAMPLE_SEED_ENABLED
admin-login-id admin SAMPLE_SEED_ADMIN_LOGIN_ID
admin-password admin SAMPLE_SEED_ADMIN_PASSWORD
admin-email admin@example.com SAMPLE_SEED_ADMIN_EMAIL

Disable in production-like runs with sample.seed.enabled=false.

application.yaml upgrades

  • Datasource block pointing at the same Postgres that devslab-kit-admin-ui's docker-compose stands up by default (jdbc:postgresql://localhost:5432/devslab_kit, devslab/devslab). All four values overridable via DEVSLAB_DATASOURCE_*.
  • Redis host/port via DEVSLAB_REDIS_*.
  • jpa.open-in-view=false (avoid the OSIV warning).
  • Explicit JWT block: secret (≥ 32 bytes for jjwt HS256), issuer, ttl — all DEVSLAB_JWT_* overridable. Default secret is dev-only and the YAML comment says so.
  • Surfaced devslab.kit.audit.async-queue-capacity and devslab.kit.menu.cache-ttl on env vars so an integration test can tighten or disable them.

Verification

  • ./gradlew build green (55 tasks)
  • SampleApplicationTests boots the full context against Testcontainers Postgres + runs the new seed runner successfully
  • Manual e2e: docker compose up -d postgres redis (in admin-ui) → ./gradlew :devslab-kit-sample-app:bootRun (in devslab-kit) → npm run dev (in admin-ui) → log in as admin / admin and walk through every CRUD page

Why now

This is the missing piece for the integration e2e verification phase. The 23 admin endpoints, the 10 UI pages, and the seed all need to line up against the same running stack for the contract gaps to be exercised end-to-end (not just per-spec in unit tests).

…fig for e2e

Sets up the sample app so the admin UI can log in immediately
against it. Needed for end-to-end verification of the full stack
(admin-ui + devslab-kit) — previously the app booted with zero
users and the UI's login screen had nothing to authenticate against.

Seed runner
-----------
- New SampleSeedRunner (ApplicationRunner) registered as a bean from
  SampleApplication. On first boot it provisions:
    * Tenant "default"
    * Role PLATFORM_ADMIN bound to that tenant
    * 16 admin.* permissions covering every admin-api endpoint
      (admin.user.read/write, admin.role.read/write, ...
       admin.permission.*, admin.group.*, admin.menu.*,
       admin.tenant.*, admin.policy.test, admin.audit.read,
       admin.diagnostics.run, admin.settings.read)
    * Each admin.* permission granted to PLATFORM_ADMIN
    * User admin / admin (configurable) with PLATFORM_ADMIN role
- Every step is idempotent (findByCode / findByLoginId before
  create). Re-running on an already-seeded DB is a no-op.
- New SampleSeedProperties (sample.seed.*) — disable with
  sample.seed.enabled=false; admin loginId / password / email
  overridable via SAMPLE_SEED_ADMIN_* env vars.

application.yaml
----------------
- Add Spring datasource block pointing at the same Postgres that
  devslab-kit-admin-ui's docker-compose stands up by default
  (jdbc:postgresql://localhost:5432/devslab_kit, devslab/devslab).
  All four values overridable via DEVSLAB_DATASOURCE_*.
- Add Redis host/port (DEVSLAB_REDIS_*).
- jpa.open-in-view=false (avoid the OSIV anti-pattern warning).
- Explicit JWT block: secret (>= 32 bytes for jjwt HS256),
  issuer, ttl — all DEVSLAB_JWT_* overridable. Default secret
  is dev-only and the YAML comment says so.
- Surface devslab.kit.audit.async-queue-capacity and
  devslab.kit.menu.cache-ttl on env vars so an integration test
  can tighten or disable them.

Verification
------------
- ./gradlew build green (55 tasks; SampleApplicationTests boots
  the full context against Testcontainers Postgres + runs the
  new seed runner successfully).
@jlc488
jlc488 merged commit 101be3d into main May 30, 2026
1 check passed
@jlc488
jlc488 deleted the feat/sample-app-seed-for-e2e branch May 30, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant